@keyframes dropdown-appear {
  from { opacity: 0; }
  to   { opacity: 1; }
}

nav {
  position: relative;

  width: 100%;
  height: 2.5rem;

  line-height: 0.9375rem;

  width: 100%;

  z-index: 3;
}
nav > .container {
  display: flex;
  width: 100%;
  height: 100%;

  background: var(--nav-bg);
  background-size: cover;
  background-position: center;

  box-shadow: var(--shadow-card);

  color: var(--nav-fg);
  fill: var(--nav-fg);

  opacity: var(--nav-opacity);
  transition: opacity 200ms ease;
}
nav:hover > .container {
  opacity: 1;
}
.narrow-nav nav {
  height: 1.75rem;
/* }
.narrow-nav nav > .container { */
  font-size: 0.875rem;
}

.history {
  display: inline-flex;
  align-items: stretch;
  align-content: stretch;
  justify-content: stretch;
  /* font-size: var(--font-size-small); */

  margin-right: 0.25rem;
  height: 100%;

  flex-grow: 1;
  flex-shrink: 0;
  flex-basis: 0%;
  line-height: 2.5rem;
  overflow-x: hidden;

  user-select: none;
  -moz-user-select: none;
  -webkit-user-select: none;
}
.narrow-nav .history {
  line-height: 1.75rem;
}

#history-icon {
  vertical-align: top;
  padding-right: 0.25rem;

  fill: var(--color-accent);
}
#history-icon:hover {
  cursor: pointer;
  background: rgba(127, 127, 127, 0.5);
}
#history-region span {
  margin-right: 0;
}
#history-region > span {
  margin-left: 0.25rem;
}
#history-region > span > small,
.smaller-lower-numbers #history-region .with-larger-digits {
  font-size: 0.8em;
}
.icon-overflow-wrap {
  display: inline-block;
  margin: 0.5rem;
  height: calc(100% - 1rem);
  overflow: hidden;
}
.narrow-nav .icon-overflow-wrap {
  margin: 0.25rem 0.125rem 0.25rem 0.25rem;
  height: calc(100% - 0.5rem);
}
.narrow-nav .icon-overflow-wrap svg {
  width: 1.25rem !important;
  transform: translateY(-0.02rem);
}

.history mark, .history span {
  vertical-align: top;
  white-space: nowrap;
  flex-grow: 0;
  flex-shrink: 0;
  cursor: inherit;
}
#history-region {
  flex-grow: 1;
  flex-shrink: 1;
  text-align: right;
}

.buttons {
  display: inline-block;
  float: right;

  height: 100%;

  flex-grow: 0;
  flex-shrink: 0;
}
.buttons * {
  display: inline-block;
  vertical-align: top;
}

.buttons > li, .buttons > li > ul {
  height: 100%;
  cursor: pointer;
}
.buttons li.label {
  font-size: var(--font-size-small);
}
.buttons li.seperator {
  width: 0;
  height: 75%;
  margin: 0.25rem;
  border-left: 0.1rem solid rgba(127, 127, 127, 0.5);
}
.buttons li.button {
  height: 100%;
  padding: 0.5rem 0.25rem;

  line-height: 0;

  background: transparent;
  transition: background-color 200ms ease;
}
.buttons li.button:hover {
  background: rgba(127, 127, 127, 0.25);
}
.buttons li.button.button-text, .dropdown li.button.button-text {
  line-height: 1.5em;
  padding: 0.25rem 0.5rem;
}
.buttons li.button.button-text.active {
  color: var(--color-accent);
}

.narrow-nav .buttons li {
  padding: 0.5rem;
}
.narrow-nav .buttons > li.dropdown-wrapper {
  width: 2rem;
}
.narrow-nav .buttons > li.dropdown-wrapper > svg {
  transform: rotate(90deg) translate(-0.375rem, -0rem);
}
.narrow-nav .buttons > li.button[data-button="toggle-detail"] svg {
  transform: translateY(-0.72rem);
}

/* Icon transitions */
.icon-container {
  display: inline-block;
  height: 100%;
  overflow: hidden;
  transition: background-color 200ms ease;
}
.icon {
  position: relative;
  transition: top 200ms ease;
}

:not(.enabled) > .icon-container > .icon-transition {
  top: 0 !important; /* (unfollow inline style) */
}
.enabled .when-disabled {
  display: none;
}
[data-active-by]:not(.enabled) .when-enabled {
  display: none;
}

/* Dropdown */
.dropdown-wrapper {
  position: relative;
}

.dropdown {
  display: none;
  position: absolute;
  top: 2.5rem;

  width: 10rem;
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 1rem);

  background-size: cover;
  background: var(--dropdown-bg);
  box-shadow: var(--shadow-card);

  color: var(--dropdown-fg);
  fill: var(--dropdown-fg);
  z-index: 10;

  overflow-y: auto;
}
.narrow-nav .dropdown {
  top: 1.75rem;
}
.dropdown.opened {
  display: block;
  animation: 166ms dropdown-appear;
}
.dropdown.closing {
  display: block;
  opacity: 0;
  transition: opacity 166ms ease;
}
.dropdown.left {
  left: 0;
}
.dropdown.right {
  right: 0;
}
.dropdown > li {
  display: block;
  padding: 0.5rem 0.25rem;
  transition: background-color 200ms ease;
}
.dropdown > li:hover {
  background: rgba(127, 127, 127, 0.25);
}
/* .dropdown > li > .icon {
  margin: 0 0.25rem;
} */

.dropdown .title {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  opacity: 0.5;
}
.dropdown .title:hover {
  background: none;
}

.dropdown label {
  display: inline-block;
  vertical-align: top;
  line-height: 1.5rem;
}
.dropdown .seperator {
  width: calc(100% - 0.5rem);
  height: 0;

  border-left: none;
  border-top: 0.1rem solid rgba(127, 127, 127, 0.5);
  margin: 0.25rem;
  padding: 0;
}

.dropdown-history {
  font-size: 0.75rem;
  width: 16rem;

  top: 0;
  left: 2.5rem;
}
.narrow-nav .dropdown-history {
  left: 1.5rem;
}
.dropdown-history li {
  padding: 0.25rem 0.5rem;
  height: 2.5rem;
  cursor: pointer;
}
.history-current {
  box-shadow: 0.125rem 0 0 var(--color-accent) inset;
}
.history-region, #history-region {
  opacity: 0.5;
}

.dropdown.buttons {
  width: 7.5rem;
  height: 5rem;
}
.dropdown.buttons li {
  display: inline-block;
  height: 2.5rem;
}

.legacy-overlayplugin .dropdown.buttons {
  width: 5rem;
}
.legacy-overlayplugin [data-button='end-encounter'],
.legacy-overlayplugin [data-button='screenshot'] {
  display: none !important;
}

#nav-label {
  position: absolute;
  top: calc(7.1rem + var(--body-margin));
  right: var(--body-margin);

  font-size: 0.75rem;
  padding: 0.25rem;

  background: #f00;
  color: #0f0;

  background-size: cover;
  background: var(--dropdown-bg);
  box-shadow: var(--shadow-card);

  color: var(--dropdown-fg);
  fill: var(--dropdown-fg);

  z-index: 10;

  opacity: 0;
  transition: 200ms opacity ease;
}
.buttons:not(.closed):hover + #nav-label {
  opacity: 1;
}
